/*
* Copyright (C) 2012-2014 qar
* License: http://www.gnu.org/licenses/gpl.html GPL version 2
*/

#ifndef HASHFUNCTION_H
#define HASHFUNCTION_H

#include <QtCore>

class HashFunction
{
public:
    HashFunction();
    virtual ~HashFunction();

    virtual qint64 hashSize() const = 0;
    virtual QString getAlgorithmName() const = 0;

    // Online hash functions
    virtual void reset() = 0;
    void addData(const QByteArray &data);
    virtual void addData(const char *data, int length) = 0;
    virtual QByteArray result() const = 0;

    // Offline hash functions
    virtual QByteArray offlineHash(const QByteArray &data) const = 0;

    // Serialization of parameters
    virtual bool toStream(QDataStream &s);
    virtual bool fromStream(QDataStream &s);

private:
    Q_DISABLE_COPY(HashFunction)
};

#endif // HASHFUNCTION_H
